datetime: convert timestamptz to local timezone#21
datetime: convert timestamptz to local timezone#21TheJJ wants to merge 1 commit intoMagicStack:masterfrom
Conversation
|
can this please be merged? |
|
This is technically a backwards-incompatible change as clients might stringify returned |
|
Would you be willing to implement that? Or is there another way of defaulting timezone-including datetime objects? |
| dt = pg_epoch_datetime_utc.__add__( | ||
| timedelta(0, seconds, microseconds)) | ||
| # convert to current system timezone | ||
| return dt.astimezone() |
There was a problem hiding this comment.
This is almost certainly not what you want. astimezone() creates a broken fixed-offset timezone object that does not do DST. This exists because python did not use to have a proper timezones implementation, but it has zoneinfo now. A better way would be to have a timezone object in settings, defaulting to UTC, and do astimezone(settings.timezone) here.
This fixes MagicStack/asyncpg#1006 :)